<?php

/*

  Action - Attack	$5

  +1 Action
  Choose one: +$2; or discard your hand, +4 Cards; and each other player with at least 5 cards in hand discards his hand and draws 4 cards.

 */

class Minion extends Card implements iAction, iKingdom, iAttack, iIntrigue {

    public function __construct() {
        parent::__construct("Minion", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Action",
            "",
            "Choose one: +$2; or discard your hand, +4 Cards; and each other player with at least 5 cards in hand discards his hand and draws 4 cards.");
    }
    
    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 action", "gets +1 action");
        
        $game->attack($this);
        
        $options = array(new Option(1, "2$"), new Option(2, "discard hand and draw 4 cards"));
        
        $output = MySocket::GetUserReply($game,  Input_ChooseOne,  $options, 1, 1, null, "Please choose");
        $answer = $output[0];
        if ($answer == 'discard hand and draw 4 cards') {
            $game->discardPlayHand();
            $drawed_cards = $game->drawCards(4);
             ScreenDisplay::addScreenMessage($game, false, " and draw " . nicePrint($drawed_cards), " and draws ".sizeof($drawed_cards). " cards");
            
            $names = $game->getOtherPlayersNames(true);
            foreach ($names as $name) {
                $cards_num = $game->getPlayHandSize($name);
                if ($cards_num > 4) {
                    $game->discardPlayHand($name);
                    $drawed_cards = $game->drawCards(4, $name);
                     ScreenDisplay::addScreenMessage($game, true, "discard your hand and draw " . nicePrint($drawed_cards), "discards his hand and draws ".  sizeof($drawed_cards). " cards", $name);
                }
            }
        } else {
            $game->addMoney(new Price(2));
             ScreenDisplay::addScreenMessage($game, true, "get +2$", "gets +2$");
        }
        $game->cardActionFinished();
        return true;
    }
}

?>